﻿using SQLServer.DBUtility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using Tenancy.Helper;

namespace Tenancy.Server
{
    /// <summary>
    /// Hbung_FavourablePrice 的摘要说明
    /// </summary>
    public class Hbung_FavourablePrice : IHttpHandler
    {
        /// <summary>
        /// 获取优惠折扣接口
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            ////用户登录的手机号
            //string Hbung_Tel = context.Request.Params["Tel"];
            //string Hbung_Phone = string.Empty;
            //if (string.IsNullOrEmpty(Hbung_Tel))
            //{
            //    context.Response.Write(GenerClass.SetParamErrorJsData("Tel为空"));
            //}
            //else
            //{
            //    string pattern = "^1[0-9]{10}$"; //正则表达式字符串
            //    Regex cgsregex = new Regex(pattern);
            //    Hbung_Phone = DESEncrypt.MD5Decrypt(Hbung_Tel);
            //    bool isMatch = cgsregex.IsMatch(Hbung_Phone);
            //    if (!isMatch)
            //    {
            //        context.Response.Write(GenerClass.SetParamErrorJsData("Tel格式不正确"));
            //        return;
            //    }
            //}
            ////签名
            //string HBsign = context.Request.Params["Sign"];
            //if (string.IsNullOrEmpty(HBsign))
            //{
            //    context.Response.Write(GenerClass.SetParamErrorJsData("Sign为空"));
            //    return;
            //}
            //else
            //{
            //    if (GenerClass.IsOkMatch(Hbung_Phone) != Regex.Replace(HBsign, @"\s", "+"))
            //    {
            //        context.Response.Write(GenerClass.SetParamErrorJsData("Sign不匹配"));
            //        return;
            //    }
            //}

            string Strs = string.Format("select top 1 Value from Hbung_Parame where type='0'");
            DataTable HB_ComInfo = DBHelpSQL.Query(Strs).Tables[0];
            if(HB_ComInfo!=null&&HB_ComInfo.Rows.Count>0)
            {
                context.Response.Write(GenerClass.GetJsonTable("查询成功", HB_ComInfo.Rows[0]["Value"].ToString()));
            }
            else
            {
                context.Response.Write(GenerClass.SetChangeErrorJsData("查无数据"));
                return;
            }
           
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}